Final Project

Imports

Summary

This is the exploration of a spread trading stategy involving BTCUSDT and BTCUSDT perpetual futures contracts on the binance exchange.

Overview

The basic strategy is to receive the funding rate when it is attractive and taking advantage of the fact the perptual contract and underlying asset prices converge over time as as result of the funding rate. We do this by tracking the funding rate and shorting the perpetual contract and going long the underlying asset when the funding rate is high and closing positions when the funding rate comes back down. If the funding rate goes sufficiently negative, we go long the perpetual contract and short the underlying asset.

Funding Rate

The perptual futures contract has a funding rate that are periodic payments made to either short or long traders based on the difference in the perpetual futures price and the spot price. When the market is bullish - perpetual futures price greater than the spot price - the funding rate is positive and long traders pay short traders. When it is bearish, the funding rate is negative and short traders pay long traders.

Funding rate payments are made every 8 hours starting at 00:00 UTC and only gets paid if positions are held at the designated time.

The actual rate has two components, an interest rate and a premium. The interest rate is set by the exchange and may change based on market conditions, such as changes in the federal funds rate. The current interest rate is 0.01% per eight hours, which equates to 0.03% per day or 10.8% per year. The premium is determined based on the bid ask spread relative to an index formed from a bucket of prices from major spot market exchanges need to understand better. At this point, to begin evaluating the strategy, we use the historical funding rates as provided by the exhange, and have on the todo list a fuller understanding of the mechanics of determining the funding rate.

Liquidation

Both assets are subject to automatic liquidation when collateral = initial collateral + realized and unrealized profits and losses is less than the maintenance margin. Maintenance margin is determined based on position size an leverage. Perpetual futures contracts can be traded with leverage up to 125x. need to understand better

Markets

Perpetual Contract

Spot Prices

These are the same prices as above.

Funding Rate

It looks like the funding rate rarely goes negative. Is that because the perpetual price rarely goes below the spot price or is there something structural that may present and arbitrage opportunity going on?

The cumulative funding rate essentially shows what return would have been generated by opening one trade short the perpetual and long the spot and holding it for the entire period.

Spread

This is of the spread itself - the percentage difference between the perpetual and spot prices and excludes a spread outlier on 2020-12-21 of 0.018.

This shows that the difference in returns between the perpetual and the spot basically revert to zero over time, which means that there is profit to be made in chasing the funding rate, shorting the perpetual while going long the underlying asset to get the funding rate.

Funding Rate Strategy

This strategy is essentially designed to capture the funding rate, shorting the perpertual and going long the underlying asset when the funding rate is high.

A better strategy would be to simply hold a short position in the perpetual and a long position in the spot and close it out much less frequently in order to avoid transaction costs.

Spread Strategy

Here we trade on the spread, increasing the open threshold, but it doesn't actually do much better than the funding rate only strategy, since the bulk of the profit comes from one trade on an outlier.

Spread Strategy - 1 Minute Intervals

Funding Rate Strategy - ETH

Liquidation Price

Example

Calculate liquidation price in One-way & Cross margin mode